package com.ndp.fb.creative.fetchdata.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.Map;

/**
 * Created by Evan on 2015/5/20 22:47.
 * Email evan.wan@ndpmedia.com
 */
@Controller
public class SimpleController
{
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Value("${application.message:Hello World}")
    private String message = "Hello World1";

    @Value("${name}")
    private String name;



    @RequestMapping(value ="/hello", method = RequestMethod.GET)
    @ResponseBody
    public String hello(){

        return message;
    }

    @RequestMapping("/")
    //@ResponseBody
    public String welcome(Map<String, Object> model) {
        logger.info("xxx");
        model.put("time", new Date());
        model.put("message", this.message);
        return "welcome";
    }

    @RequestMapping("/index")
    public String index(Map<String, Object> model) {
        logger.info("xxx");
        model.put("time", new Date());
        model.put("message", this.message);
        return "index";
    }


    @RequestMapping("/view")
    public String view(Map<String, Object> model) {

        //System.out.println( testMapper.selectTest() );

        model.put("time", new Date());
        model.put("message", this.message);
        return "view";
    }
}
